# clear environment
rm(list=ls())

# load packages
library(ggplot2)
library(openxlsx)

# load data set with crime numbers
dat <- openxlsx::read.xlsx("vsberichte_metadata.xlsx", sheet = 1)

# filter federal level
bund = dat[dat$jurisdiction=="bund",]
bund = bund[,c("year", "extreme_crime_violent_physical_right", "extreme_crime_violent_physical_left")]

# add 2024 numbers
bund_24 = c(2024, 1127, 216)
bund = rbind.data.frame(bund, bund_24)


# figure
ggplot(data=bund) + 
  geom_point(aes(x=as.numeric(year), y=extreme_crime_violent_physical_right, color="Right", shape="Right"), size=2.5) +
  geom_line(aes(x=as.numeric(year), y=extreme_crime_violent_physical_right, color="Right")) +
  geom_point(aes(x=as.numeric(year), y=extreme_crime_violent_physical_left, color="Left", shape="Left"), size=2.5) +
  geom_line(aes(x=as.numeric(year), y=extreme_crime_violent_physical_left, color="Left")) +
  xlab("") + ylab("Violent Crimes\n(Killings and Assaults)") +
  theme_classic() +
  scale_color_manual(values=c("firebrick", "dodgerblue"), name="Type of Extremism", labels=c("LWE", "RWE")) +
  scale_shape_manual(values=c(16, 17), name="Type of Extremism", labels=c("LWE", "RWE")) +
  theme(legend.position = "bottom", text=element_text(size=14)) +
  scale_x_continuous(limits=c(1969, 2025)) +
  scale_y_continuous(breaks=seq(0, 1250, 250))

ggsave("FigD1.pdf", width=7, height=5)
